﻿using FreeSql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using XKPlatform.DataModels.Dao.BaseEntity;

namespace XKPlatform.IService.IBaseService
{
    public interface IFreeBaseService<T> where T : class
    {
        bool AddModel(T model);
        bool UpdateModel(T model, Expression<Func<T, bool>> where, Expression<Func<T, object>> IgnoreLmbad = null);
        bool BatchSave(List<T> models);
        T GetModel(Expression<Func<T, bool>> where);
        bool Delete(Expression<Func<T, bool>> where);
        (List<T> list, long count) GetList(Expression<Func<T, bool>> where,
            List<SortInfo<T, object>> orderbys = null, PageInfo pageInfo = null);
        (List<T> list, long count) GetListByTbName(Expression<Func<T, bool>> where,
      
            string tbName, List<SortInfo<T, object>> orderbys = null, PageInfo pageInfo = null);
        /// <summary>
        /// _iservice.UpdateBySets(o => o.ID == save.ID).Set(a => a.UserName == "ceshi").Set(a => a.IPAddress == "12222").ExecuteAffrows();
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        IUpdate<T> UpdateBySets(Expression<Func<T, bool>> where);
    }
}
